/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Lotr.game.GUI;

import Lotr.game.Game;
import java.io.IOException;
import javax.swing.JOptionPane;


/**
 *
 * @author Weed
 */
public class MainFrame extends javax.swing.JFrame {

private Game game;
    /**
     * Creates new form MainFrame
     */
    public MainFrame() {
        setUndecorated(true);
        initComponents();
        try {
            game = new Game(800, 600);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        pnGame = new javax.swing.JPanel();
        frDebug = new javax.swing.JFrame();
        lbHealth = new javax.swing.JLabel();
        pbHealth = new javax.swing.JProgressBar();
        pnMainMenu = new javax.swing.JPanel();
        btStart = new javax.swing.JButton();

        javax.swing.GroupLayout pnGameLayout = new javax.swing.GroupLayout(pnGame);
        pnGame.setLayout(pnGameLayout);
        pnGameLayout.setHorizontalGroup(
            pnGameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        pnGameLayout.setVerticalGroup(
            pnGameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        frDebug.getContentPane().setLayout(new java.awt.GridBagLayout());

        lbHealth.setText("Health:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        frDebug.getContentPane().add(lbHealth, gridBagConstraints);

        pbHealth.setValue(100);
        pbHealth.setStringPainted(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipady = 8;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        frDebug.getContentPane().add(pbHealth, gridBagConstraints);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        pnMainMenu.setLayout(new java.awt.GridBagLayout());

        btStart.setText("Start");
        btStart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                onStartGame(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(172, 172, 172, 172);
        pnMainMenu.add(btStart, gridBagConstraints);

        getContentPane().add(pnMainMenu, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void onStartGame(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onStartGame
       pnMainMenu.setVisible(false);
       remove(pnMainMenu);
       add(pnGame);
       pnGame.add(game);
       pnGame.setVisible(true);
       game.setVisible(true);
       this.setSize(800, 600);
       frDebug.setVisible(true);
       frDebug.pack();
       game.start(this);
    }//GEN-LAST:event_onStartGame

    public void setHealtProgress(int health){
        pbHealth.setValue(health);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btStart;
    private javax.swing.JFrame frDebug;
    private javax.swing.JLabel lbHealth;
    private javax.swing.JProgressBar pbHealth;
    private javax.swing.JPanel pnGame;
    private javax.swing.JPanel pnMainMenu;
    // End of variables declaration//GEN-END:variables
}
